< previous page page_723 next page >

Page 723
Here are some examples of better procedure names:
FormShow
FormInit
cboStateLoad
The difference is the noun, or object, is placed first. There are fewer ways to describe an object than there are for a verb to describe what will be done. For example, the verb display can be expressed a couple other ways, such as show,draw, or even print. However, a form is always a form, theres no other descriptor for it.
In object-oriented languages and even in VB, the object name is placed first and then the method or action you want to perform on that object. Objects are always nouns, and actions are verbs. You should follow this coding style when creating names for your procedures.
An additional benefit of this coding style is that when you use a cross-referencing tool or are looking in the Proc combo box, youll see all functions that operate on a particular object grouped in one place.
Error Labels
Labels in a procedure should only be used for error handling. Otherwise, too many programmers would be tempted to use the GoTo statement. A GoTo statement can lead to many problems. Name your labels with the name of the procedure followed by the suffix _EH. Heres an example:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdSave_Click()
   On Error GoTo cmdSav_Click_EH
   ...
   ...
cmdSave_Click_EH:
   ' Error handling here
End Sub

 
< previous page page_723 next page >

If you like this book, buy it!